{include file="Public:header" /}
<style>
	.pagination{
		margin:5px 0px;
	}
	.pagination a{
		background-color: #f4f4f4;
		z-index: 2;
		border:1px solid #000;
		border-color: rgb(221, 221, 221);
		padding: 4px 10px;
		margin:0px 0px;
	}
	.pagination .current{
		background-color: #1ab394;
		z-index: 2;
		border:1px solid #000;
		border-color: #1ab394;
		padding: 4px 10px;
		margin:0px 0px;
		color:#fff;
	}
	.select_no_border{
		border-right: none;
	}
	.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{
		padding:0px 5px;
		text-align: center;
		vertical-align: middle!important;
	}
</style>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<h5>申请列表</h5>
					<div class="ibox-tools" style="margin-top: -6px;">
						<a href="__MODULE__/{$Think.CONTROLLER_NAME}/{$Think.ACTION_NAME}" class="btn btn-primary"><i class="fa fa-refresh"></i> 刷新</a>
					</div>
				</div>
				<div class="ibox-content">
					<div class="row">
						<div class="col-sm-3">
							<a href="__URL__/proposerAdd" class="btn btn-primary">
								<span class="fa fa-plus"></span>
								添加申请
							</a>
						</div>
						<form class="form-inline" action="__URL__/proposerList" method="get">
							<div class="col-sm-9">
								<div class="input-group col-sm-4  pull-right">
									<input type="text" name="facilitator_name" value="{:I('facilitator_name')}" placeholder="请输入单位名称" class="input-sm form-control">
									<span class="input-group-btn">
										<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
									</span>
								</div>
								<div class="input-group col-sm-2 pull-right">
									<input type="text" name="mobile" value="{:I('mobile')}" placeholder="请输入电话号码" class="input-sm form-control select_no_border">
								</div>
								<div class="input-group col-sm-2 pull-right">
									<select name="status" class="input-sm form-control select_no_border">
										<option value="">请选择审核状态</option>
										<option {if condition="I('status') eq 1"} selected {/if} value="1">待审核</option>
										<option {if condition="I('status') eq 2"} selected {/if} value="2">已通过</option>
										<option {if condition="I('status') eq 3"} selected {/if} value="3">不通过</option>
									</select>
								</div>
								<div class="input-group col-sm-2 pull-right">
									<select name="type" class="input-sm form-control select_no_border">
										<option value="">请选择申请类型</option>
										<option {if condition="I('type') eq 1"} selected {/if} value="1">基地服务商</option>
										<option {if condition="I('type') eq 2"} selected {/if} value="2">酒店服务商</option>
										<option {if condition="I('type') eq 3"} selected {/if} value="3">交通服务商</option>
									</select>
								</div>

							</div>
						</form>
					</div>

					<br />

					<div class="table-responsive">
						<form id="allDelForm" action="__URL__/deleteAll" method="post" >
							<input type="hidden" name="model" value="facilitator_proposer">
							<table class="table table-bordered table-hover"
								   id="categoryTable">
								<thead>
								<tr class="active">
									<th><input onclick="choosebox(this)" type="checkbox" /></th>
									<th height="40">编号</th>
									<th>用户名</th>
									<th>单位名称</th>
									<th>电话</th>
									<th>邮箱</th>
									<th>地址</th>
									<!--<th>材料图片</th>-->
									<th>申请类型</th>
									<th>审核状况</th>
									<th  width="10%">申请时间</th>
									<th width="100">操作</th>
								</tr>
								</thead>
								<tbody>
								{foreach name="data" item="data"}
								<tr>
									<td><input type="checkbox" name="id[]" value="{$data['id']}" /></td>
									<td>{$data['id']}</td>
									<td>{$data['nickname']}</td>
									<td>{$data['facilitator_name']}</td>
									<td>{$data['mobile']}</td>
									<td>{$data['email']}</td>
									<td>{$data['address']}</td>
									<!--<td><img src="{$data['smallimage']}"></td>-->
									<td>
										{switch name="data['type']"}
										{case value="1"}基地服务商{/case}
										{case value="2"}酒店服务商{/case}
										{case value="3"}交通服务商{/case}
										{/switch}
									</td>
									<td style="padding: 0px;">
										<div style="width: auto;border:none;">
											<select style="border:none;" class="form-control" onchange="updateStatus({$data['id']}, 'facilitator_proposer',this.options[this.options.selectedIndex].value)">
												<option {if condition="$data['status'] eq 1"} selected {/if} value="1">待审核</option>
												<option {if condition="$data['status'] eq 2"} selected {/if} value="2">已通过</option>
												<option {if condition="$data['status'] eq 3"} selected {/if} value="3">不通过</option>
											</select>
										</div>
									</td>
									<td>{$data['add_time']|date="Y-m-d H:i",###}</td>
									<td class="center">
										<div class="dropdown">
											<button class="btn btn-primary dropdown-toggle"
													type="button" id="dropdownMenu1" data-toggle="dropdown"
													aria-haspopup="true" aria-expanded="true">
												操作
												<span class="caret"></span>
											</button>
											<ul class="dropdown-menu" style="min-width: 90px;" aria-labelledby="dropdownMenu1">
												<li>
													<a role="button" class="btn btn-primary"
													   style="margin-bottom: 0px;"
													   href="__URL__/proposerEdit?id={$data['id']}">
														<span class="fa fa-edit"></span>
														查看
													</a>
												</li>
												<li>
													<a role="button" class="btn btn-danger"
													   style="margin-bottom: 0px;"
													   onclick="deleteData(this,{$data['id']},'facilitator_proposer')" href="javascript:void(0);">
														<span class="fa fa-trash-o"></span>
														删除
													</a>
												</li>
											</ul>
										</div>
									</td>
								</tr>
								{/foreach}
								</tbody>
							</table>

						</form>
						<div style="padding-left:0px;" class="col-sm-3 text-left">
							<button id="allDel" class="btn btn-danger">删除</button>
						</div>
						<div class="col-sm-12 text-right">
							<nav aria-label="Page navigation">
								<ul class="pagination">
									{$page}
								</ul>
							</nav>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
{include file="Public:footer" /}
<script>
    function choosebox(o){
        var vt = $(o).is(':checked');
        if(vt){
            $('input[type=checkbox]').prop('checked',vt);
        }else{
            $('input[type=checkbox]').removeAttr('checked');
        }
    }
    $("#allDel").click(function () {
        layer.confirm('确定要删除数据吗', {btn: ['确认', '取消'], icon: 3, closeBtn: 2}, function (index) {
            $("#allDelForm").submit();
        });
    })
</script>


<script>
	$(document).ready(function () {
	    $(".pagination li").eq(0).removeClass('disabled');
    });
</script>

<script>
    $(document).ready(function() {
        /**
         * 下面是进行插件初始化
         * 你只需传入相应的键值对
         * */
        $('#defaultForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {/*输入框不同状态，显示图片的样式*/
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/*验证*/
                shop_name: {/*键名username和input name值对应*/
                    message: '商品名称验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品名称不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品名称长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_address: {/*键名username和input name值对应*/
                    message: '商品地址验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品地址不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品地址长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_tel: {/*键名username和input name值对应*/
                    message: '商品电话验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品电话不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品电话长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_description: {/*键名username和input name值对应*/
                    message: '商品描述验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品描述不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品描述长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_coord:{/*键名username和input name值对应*/
                    message: '商品坐标验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品坐标不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品坐标长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                metro_address:{/*键名username和input name值对应*/
                    message: '地铁地址验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '地铁地址不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '地铁地址长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                }

            }
            // 还有一个比较常用的就是submitHandler属性，它对应着提交按钮的事件方法。
            // submitHandler: function (validator, form, submitButton) {
            //alert("submit");
			/*  var menu_name = $("input[name='menu_name']").val();
			 var link = $("input[name='link']").val();
			 var ico = $("input[name='ico']").val();
			 $.ajax({
			 url : '__URL__/addMenu',
			 type : 'get',
			 data : {'menu_name' : menu_name, 'link' : link, 'ico':ico},
			 dataType : 'json',
			 success : function(data){
			 alert(data.message);
			 }
			 }); */
            // }
        });
    });


    //删除
    function deleteData(obj, id,model){
        layer.confirm('确定要删除数据吗',{btn:['确认','取消'], icon:3, closeBtn: 2 },function(index){
            $.ajax({
                url : '__URL__/dataDel',
                data : {'id':id,model:model},
                type : 'get',
                dataType : 'json',
                async : false,   //取消同步，执行完之后再往下执行
                success : function(data){
                    if(data.status == 1){
                        layer.msg(''+data.message+'',{icon:2,time:1000});
                        $(obj).parent('li').parent('ul').parent('div').parent('td').parent('tr').remove();
                    }else if(data.status == 2){
                        layer.msg(''+data.message+'',{icon:1,time:1000});
                    }
                }
            });
        });
    }

	//状态
    function updateStatus(Id,model,status) {
        $.ajax({
            url : "__URL__/statusEdit",
            type : "GET",
            dataType : "JSON",
            data : {
                Id : Id,
				model:model,
                status : status,
            },
            success : function(data) {
                if(data.status == 1) {
                    layer.msg('操作成功',{time:2000});
                } else {
                    layer.msg('操作失败',{time:2000});
                }
            }
        });
    }
</script>
</body>
</html>
